
#ifndef NODE_H_
#define NODE_H_

#include <vector>
#include "RT.h"
#include "UnBoundMailBox.h"
#include "Message.h"
#include "OSThread.h"

using namespace std;
class Mailer;

class Node : public OSThread{
public:
	Node(vector<int> neighborNme,Mailer* mailer );
	virtual ~Node();
	int getId();
	vector<int> getNeighbors();
	void printNeighbors();
	void InitRT(vector<int> nodesInGraph);
	RT* getRT();
	void PrintRT();
	void run();
	void stop();
	void sendRT();
	int getNeighborsNumber();
	bool studentSend(void *args);
	bool studentRecv(void **args);
	void addLast(Message* msg);
	void addFirst(Message* msg);
	bool isBlocked();
	void FirstSend();
	void revive();
	bool isYield();
	int getInboxSize();
	bool isStable();
	bool IsActive();

private:
	int _Id;
	RT* _rt;
	UnBoundMailBox* _inbox;
	vector<int> _neighbors;
	bool _continue;
	void printVector(vector<int> v);
	Mailer* _mailer;
	bool _yield;
	bool _stable;
	int _stepStableCounter;
};

#endif /* NODE_H_ */
